package au.com.twosquared.tools;

import java.util.ArrayList;

public class Shop extends ArrayList<Item> {

	int money;

	public void buy(Inventory inv, int ID, int amount) {
		for (Item i : this) {
			if (i.getID() == ID) {
				if ((money -= amount) < 0) {
					System.out.println("You don't have enough money");
				} else
					inv.addInventory(ID, amount);
			}
		}
	}

	public void sell(Inventory inv, int ID, int amount) {
		for (Item i : this) {
			if (i.getID() == ID) {
				if (amount > i.getAmount()) {
					System.out.printf("You don't have enough %d", i.getName());
				} else {
					inv.useInventory(ID, amount);
					money += ((amount * i.getCost()) / 2);
				}
			}
		}
	}
}
